package com.doit.day01;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.tool.LoadIncrementalHFiles;

import java.io.IOException;

public class _04_hfile文件得迁移 {
    public static void main(String[] args) throws Exception {

        //需要用saprk去写
        System.setProperty("HADOOP_USER_NAME","root");
        Configuration conf = HBaseConfiguration.create();
        conf.set("hbase.zookeeper.quorum","linux01:2181");

        Connection conn = ConnectionFactory.createConnection(conf);
        Admin admin = conn.getAdmin();
        Table table = conn.getTable(TableName.valueOf("doit:user_info1"));
        RegionLocator regionLocator = conn.getRegionLocator(TableName.valueOf("doit:user_info1"));

        LoadIncrementalHFiles load = new LoadIncrementalHFiles(conf);
        load.doBulkLoad(new Path("hdfs://linux01:8020/out/"),admin,table,regionLocator);

    }
}
